/**
 * @author iLakeYC
 */
+function ($) {

    $.setWindowLocation = function (url, object) {
        if (object) {
            var j = JSON.stringify(object);
            if (url.toString().indexOf("?") >= 0) {
                url += "&"
            } else {
                url += "?"
            }
            j=encodeURI(j);
            url += "sending_message=" + j
        }
        window.location.href = url;
    };

    $.getSentMessage = function () {
        var url = window.location.href;
        if (url.indexOf("?") < 0) {
            return null;
        }
        var _foo = url.split("?");
        if (_foo.length <= 1) {
            return null;
        }
        var queries = _foo[1].split("&");
        for (var index in queries) {
            var query = queries[index];
            if (query.indexOf("sending_message=") >= 0) {
                query = query.replace(/sending_message=/g, "");
                query = decodeURI(query);
                return JSON.parse(query);
            }
        }
    }
    
    $.getSentMessageOrder = function () {
        var url = window.location.href;
        if (url.indexOf("?") < 0) {
            return null;
        }
        var _foo = url.split("?");
        if (_foo.length <= 1) {
            return null;
        }
        var queries = _foo[1].split("&");
        for (var index in queries) {
            var query = queries[index];
            if (query.indexOf("sending_message=") >= 0) {
                query = query.replace(/sending_message=/g, "");
                query = decodeURI(query);
                return query;
            }
        }
    }

}($);